#include <stdio.h>
#include <string.h>
static const char *haab_months[19] = {
    "pop", "no", "zip", "zotz", "tzec", "xul",
    "yoxkin", "mol", "chen", "yax", "zac", "ceh", 
    "mac", "kankin", "muan", "pax", "koyab", "cumhu",
    "uayet"
};

static const char *tzol_days[20] = {
     "imix", "ik", "akbal", "kan", "chicchan",
     "cimi", "manik", "lamat", "muluk", "ok",
     "chuen", "eb", "ben", "ix", "mem",
     "cib", "caban", "eznab", "canac", "ahau"
};

static int find_str(const char *arr[], const char *s)
{
    int i;
    for (i = 0; strcmp(arr[i], s) != 0; i++);
    return i;
}

int main()
{
    int n, i;
    scanf("%d", &n);
    printf("%d\n", n);
    for (i = 0; i < n; i++)
    {
        int haab_day, haab_month, haab_year;
        int days, tzol_year;

        char haab_month_str[10];
        scanf("%d. %s %d", &haab_day, haab_month_str, &haab_year);
        haab_month = find_str(haab_months, haab_month_str);
        days = 365*haab_year + 20*haab_month + haab_day;

        tzol_year = days / 260;
        days %= 260;
        printf("%d %s %d\n", days % 13 + 1, tzol_days[days % 20], tzol_year);
    }
    return 0;
}
